import React, {Component} from 'react';
import { connect } from 'react-redux';
import CommentItem from './CommentItem/CommentItem'
/**
 * @desc 评价列表
 */
class CommentList extends Component {
    constructor(props) {
        super(props);
        this.state = {};
    }

    // 渲染列表
    renderList(){
        let list = this.props.commentData.comments;
        if(list) {
            return list.map((item, index)=>{
                return <CommentItem key={index} data={item}></CommentItem>
            })
        }

    }

    render() {
        return (
          <div className="comment-list">
              {
                  this.renderList()
              }
          </div>
        )
    }
}

export default connect(
    (state) => ({
        commentData: state.commentReducer.commentData
    })
)(CommentList)
